<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/*
**********************************************
JoomLeague NAVIGATION MENU MODULE 
Copyright (c) 2007 JoomLeague.de
**********************************************
This program is free software; you can redistribute it and/or modify 
it under the terms of the GNU General Public License as published by 
the Free Software Foundation; either version 2 of the License, or 
(at your option) any later version.

This header must not be removed. Additional contributions/changes
may be added to this header as long as no information is deleted.
**********************************************

* NAVIGATION MENU MODULE
*
* 2007-08-31 - Version 0.91
*
* Displays a navigation menu for selected project.
* JoomLeague Team in a selected Project 
* There are some options for this module, which can be set in the 
* "Parameters" section of the module in Administration.
*

**********************************************
Get the latest version of JoomLeague at:
http://www.joomleague.de
**********************************************
*/

class mod_joomleague_navigation_menu {
function project_dropdown ($project_id, &$ausgabehtml, &$params, $JLItemid) {
	global $database;
	$selectedoptionsvalue='';
	$pselect=$ausgabehtml['menupunktbeginn'];
	$menuurl="index.php?option=com_joomleague&amp;func=$params->project_start&amp;Itemid=$JLItemid&amp;p=";
	$selectoptions[]= mosHTML::makeOption('', $params->text_project_dropdown);
	$query="SELECT p.id, p.name FROM #__joomleague AS p 
	LEFT JOIN #__joomleague_seasons s ON p.season_id = s.id
	LEFT JOIN #__joomleague_leagues l ON p.league_id = l.id
	WHERE p.published=1 ORDER BY s.ordering, l.ordering";
	$database->setQuery($query);
	$rows = $database->loadObjectList();
	foreach ($rows AS $row) {
		$thismenuurl='';
		if ($params->stringlength&&strlen($row->name)>$params->stringlength) $selecttext=substr($row->name,0,$params->stringlength)."...";
		else $selecttext=$row->name;
		$thismenuurl=sefRelToAbs($menuurl.$row->id);
		if ($row->id==$project_id) $selectedoptionsvalue=$thismenuurl; 
		$selectoptions[] = mosHTML::makeOption($thismenuurl, $selecttext);
	}
	$projectlist = mosHTML::selectList( $selectoptions, 'jl_p', "class=\"inputbox\" onchange=\"javascript:if (this.options[this.options.selectedIndex].value!='') gotoproject(this.options[this.options.selectedIndex].value);\" style=\"font-size:9px;width:99%\"",'value', 'text', $selectedoptionsvalue );
	$pselect.='<form action="" style="display:inline">'.$projectlist.'</form>'.$ausgabehtml['menupunktende'];
	echo $pselect;
}
function makeJLnavlinks ($joomleague, &$ausgabehtml, $menuclass, $what, $linklabel, $params, $JLItemid, $jl_func) {
	global $mainframe, $my, $database;
	$teamlist='';
	$linktext='';
	$selectoptions=array();
	if ($joomleague->id >0) {
		switch (strtolower($what)){
			case "seperator":
				$linktext = $ausgabehtml['menupunktbeginn'].$linklabel.$ausgabehtml['menupunktende'];
				break;
		case 'showuser':
			if ($joomleague->joomleague_tip ==1&&$my->id>0) {
				$query = "SELECT id FROM #__joomleague_tip_members WHERE user_id = ".$my->id." AND project_id = ".$joomleague->id." LIMIT 1";
				$database->setQuery($query);
				if ($access =$database->loadResult()) {
					$linktext= $ausgabehtml['menupunktbeginn'].'<a href="';
				
					$linktextsef = 'index.php?option=com_joomleague&amp;func='.$what.'&amp;Itemid='.$JLItemid.'&amp;p='.$joomleague->id;
					$linktext .= sefRelToAbs($linktextsef);
					$linktext .='" class="'.$menuclass.'"';
					if($what==$jl_func) {
						$linktext.= ' id="active_menu"';
						if ($linklabel!="") $mainframe->appendPathWay($linklabel);
						}
						$linktext.= '>';
						$linktext.= $linklabel;
						$linktext.= '</a>'.$ausgabehtml['menupunktende'];
					}
			 	}
			break;
		case 'dotips':
		case 'showtipranking&amp;mode=all':
		case 'showtipranking':
		case 'showtipresults':
		case 'showtiprules':
			if ($joomleague->joomleague_tip ==1) {
				$linktext= $ausgabehtml['menupunktbeginn'].'<a href="';
				$linktextsef = 'index.php?option=com_joomleague&amp;func='.$what.'&amp;Itemid='.$JLItemid.'&amp;p='.$joomleague->id;
				$linktext .= sefRelToAbs($linktextsef);
				$linktext .='" class="'.$menuclass.'"';
				if($what==$jl_func) {
					$linktext.= ' id="active_menu"';
					if ($linklabel!="") $mainframe->appendPathWay($linklabel);
				}
				$linktext.= '>';
				$linktext.= $linklabel;
				$linktext.= '</a>'.$ausgabehtml['menupunktende'];
			}		
		break;
		default:
			$linktext= $ausgabehtml['menupunktbeginn'].'<a href="';
			$linktextsef = 'index.php?option=com_joomleague&amp;func='.$what.'&amp;Itemid='.$JLItemid.'&amp;p='.$joomleague->id;
			$linktext .= sefRelToAbs($linktextsef);
			$linktext .='" class="'.$menuclass.'"';
			if($what==$jl_func) {
				$linktext.= ' id="active_menu"';
				if ($linklabel!="") $mainframe->appendPathWay($linklabel);
			}
			$linktext.= '>';
			$linktext.= $linklabel;
			$linktext.= '</a>'.$ausgabehtml['menupunktende'];
		break;
	}
		echo $linktext;
	}
}
}
?>
